/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import bean.Role;
import bean.User;
import java.sql.Date;
import java.util.List;

/**
 *
 * @author Yana
 */
public class Testtt {

    public static void main(String[] args) {
        JdbcUserDao uDao = new JdbcUserDao();
        JdbcRoleDao rDao = new JdbcRoleDao();
        List<User> users = uDao.findAll();
        System.out.println(users.size());
        for (User user : users) {
            System.out.println(user);
        }
//        User user = uDao.findByEmail("sssfs");
//        System.out.println(user);

        rDao.create(new Role(6l, "userr"));
        User user1 = uDao.findByLogin("Tom");
        System.out.println(user1);
        System.out.println("********");
        System.out.println(uDao.findByEmail("ann@gmail.com"));
        System.out.println("33333333333");
//        System.out.println(rDao.findByName("Admin"));



        System.out.println(user1.getId());
        uDao.remove(user1);

        users = uDao.findAll();

        for (User userr : users) {
            System.out.println(userr);

        }
        System.out.println(users.size());


        System.out.println("********");
//        System.out.println(user.getId());

        User user2 = new User();
        user2.setId(11);
        user2.setLogin("Sarah");
        user2.setPassword("pass");
        user2.setEmail("sarah@gmail.com");
        user2.setFirstName("Sarah");
        user2.setLastName("Bars");
        user2.setBirthday(Date.valueOf("1994-01-18"));
        user2.setRole(null);
        System.out.println(user2);

        uDao.create(user2);
//        User user1 = uDao.findByLogin("Sarah");
        System.out.println(user1);
        System.out.println("********");

        users = uDao.findAll();

        for (User userrr : users) {
            System.out.println(userrr);

        }
        System.out.println(users.size());

        System.out.println("///////////");

        Role role = new Role();
        role.setName("DDDDDddd1");
        rDao.create(role);

        System.out.println(role);

        Role role2 = new Role(2, "user1");
        rDao.create(role2);
        System.out.println(role2);

        role2.setName("SuperAdmin");
        rDao.update(role2);

        Role role3 = new Role(3, "SuperUser");
        rDao.update(role3);

        rDao.remove(role3);
        System.out.println("888888888888888888888888");



    }
}
